list1 = []
dict1 = {}
dict2 = {}
with open('C:\\Users\ctvit\Desktop\sample.txt',encoding='utf-8') as f:
    for each_line in  f.readlines():
        new_str = each_line.replace('.',' ').replace(',',' ').replace('?',' ').replace('|',' ').replace(':',' ').replace('(',' ').replace(')',' ')
        list1.extend(new_str.split())
for x in list1:
    if x in dict1:
        dict1[x] += 1
    else:
        dict1[x] = 1
for k,v in dict1.items():
    dict2.setdefault(v,[])
    dict2[v].append(k)
print(dict2)
res = [(k,v) for v in sorted(dict2,reverse=True) for k in dict2[v]]
print(res[:10])
# 效率会差一些，可以想想有没有别的方法可以解决
